package cn.iocoder.yudao.module.infra.api.config;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.infra.api.config.dto.AppInfraConfigDTO;
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
import cn.iocoder.yudao.module.infra.service.config.ConfigService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zyc
 * @createDate 2024/6/18 11:21
 */
@Service
@Validated
public class InfraConfigApiImpl implements InfraConfigApi{
    @Resource
    private ConfigService configService;
    @Override
    public List<AppInfraConfigDTO> getConfigByCategory(String category) {
        List<ConfigDO> list = configService.getConfigByCategory(category);
        return BeanUtils.toBean(list,AppInfraConfigDTO.class);
    }

    @Override
    public AppInfraConfigDTO getConfigByKey(String key) {
        ConfigDO configByKey = configService.getConfigByKey(key);
        return BeanUtils.toBean(configByKey,AppInfraConfigDTO.class);
    }
}
